package com.koron.css2.meterReading.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.meterReading.bean.ReadCycleBean;
import com.koron.css2.meterReading.mapper.MrPathMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

import java.util.List;

/**
 * 抄表周期下拉列表
 *
 * @author 杨嘉慧
 * @date 2021/10/18
 */
public class ReadCycleList implements ServerInterface {

    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        try {
            MrPathMapper mapper = factory.getMapper(MrPathMapper.class);
            List<ReadCycleBean> readCycleList = mapper.readCycleList();
            MessageBean<List> res = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", List.class);
            res.setData(readCycleList);
            return res;
        } catch (Exception e) {
            logger.error("抄表周期下拉列表查询失败", e);
            return MessageBean.create(Constant.MESSAGE_INT_FAIL, "抄表周期下拉列表查询失败", void.class);
        }
    }

}
